import React, { useState } from "react";
import { add } from "../../services/student";
import InputElement from "../InputElement";
import RadioElement from "../RadioElement";
export default function Add(props) {
    let [name,setName] = useState("");
    let [age,setAge] = useState(0);
    let [gender,setGender] = useState("");
    const handleSubmit = async () => {
        await add({name,age,gender});
        props.show();
    }
    return (
        <div>
            <h2>增加学生</h2>
            <InputElement value={name} onInput={(e) => setName(e.target.value)}>姓名：</InputElement>
            <InputElement value={age} onInput={(e) => setAge(e.target.value)}>年龄：</InputElement>
            <RadioElement name="addGender" value={gender} onChange={(e) => setGender(e.target.value)} >性别：</RadioElement>
            <input type="button" value="增加" onClick={handleSubmit} />
        </div>
    );
}
